﻿using Inovout.Cloud.Models;
using Inovout.Repositories;
using NHibernate.Criterion;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Inovout.Cloud.DatabaseCluster.Repositories
{
    public class DatabaseRepository : DataObjectRepository<Inovout.Cloud.DatabaseCluster.Models.Database>
    {
        public IList<Inovout.Cloud.DatabaseCluster.Models.Database> FindByProject(Project project)
        { 
            var list = base.OpenSession().CreateCriteria<Inovout.Cloud.DatabaseCluster.Models.Database>()
               .CreateCriteria("Project", "project")
               .Add(Restrictions.Eq("project.Id", project.Id).IgnoreCase())
               .List<Inovout.Cloud.DatabaseCluster.Models.Database>();
            return list;
        }
    }
}
